package org.skycloud.mybatis;

import org.apache.ibatis.session.SqlSessionFactory;

public final class MapperFactoryBean<T> extends org.mybatis.spring.mapper.MapperFactoryBean<T> {

	private boolean externalSqlSession;

	@Override
	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
		if (!externalSqlSession) {
			super.setSqlSessionTemplate(new SqlSessionTemplate(sqlSessionFactory));
		}
	}

	@Override
	public void setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate sqlSessionTemplate) {
		super.setSqlSessionTemplate(sqlSessionTemplate);
		externalSqlSession = true;
	}
}
